package itsm.isperp.module.controller.sparepartOld;

import itsm.isperp.framework.web.controller.BaseController;
import itsm.isperp.framework.web.response.ResultMessage;
import itsm.isperp.module.entity.sparepart.SptSparepartInDetail;
import itsm.isperp.module.service.sparepart.SptSparepartInDetailService;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 备件管理控制器
 * 
 * @author lizx
 * @date 2013-9-12
 */
@Controller
@RequestMapping("sparepart/sparepartInDetail/old")
public class SptSparepartInDetailOldController extends
		BaseController<SptSparepartInDetail> {

	@Autowired
	protected SptSparepartInDetailService sptSparepartInDetailService;

	@Override
	public SptSparepartInDetailService getService() {
		return sptSparepartInDetailService;
	}

	@Override
	public String getPageTitle() {
		return "备件采购管理";
	}

	@RequestMapping("saveDetails")
	@ResponseBody
	public ResultMessage saveDetails(String relationId, String sparepartIds) {

		String[] sparepartIdArr = sparepartIds.split(",");
		sptSparepartInDetailService.batchSave(relationId, sparepartIdArr);
		return ResultMessage.success();
	}

	@RequestMapping("listBySparepartInId")
	@ResponseBody
	public List<Map<String, Object>> listBySparepartInId(String sparepartInId) {

		return this.sptSparepartInDetailService
				.findAllDetailBySparepartInId(sparepartInId);
	}
	

}
